<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>配送方式 - Powered By ${systemConfig.systemName}</title>
    <meta name="Author" content="E-SHOP Team" />
    <meta name="Copyright" content="E-SHOP" />
    <% include("/WEB-INF/views/common/include.html"){}%>
    <link href="${base}/res/css/common.css" rel="stylesheet" type="text/css" />
    <script src="${base}/res/plugins/hplus/js/plugins/layer/layer.min.js"></script>
    <script type="text/javascript">
        function check(){
            var deliveryTypeName=$("#deliveryTypeName").val();
            var firstWeight=$("input[name='deliveryType.firstWeight']").val();//首重量
            var continueWeight=$("input[name='deliveryType.continueWeight']").val();//续重量
            var firstWeightPrice=$("input[name='deliveryType.firstWeightPrice']").val();//首重价格
            var continueWeightPrice=$("input[name='deliveryType.continueWeightPrice']").val();//续重价格
            var deliveryTypeOrderList=$("#deliveryTypeOrderList").val();
            var regNumber=/^[0-9]+(.[0-9]*)?$/;
            var listReg=/^\d*\d*\d+$/;

            if(!deliveryTypeName){
                layer.msg("请填写配送方式名称!");
                return false;
            }
            if(!regNumber.test(firstWeight)){
                layer.msg("首重量只能是大于或等于零的数字!");
                return false;
            }
            if(!regNumber.test(continueWeight)){
                layer.msg('续重量只能是大于或等于零的数字');
                return false;
            }
            if(!regNumber.test(firstWeightPrice)){
                layer.msg('首重价格只能是大于或等于零的数字');
                return false;
            }
            if(!regNumber.test(continueWeightPrice)){
                layer.msg('续重价格只能是大于或等于零的数字');
                return false;
            }
            if(!listReg.test(deliveryTypeOrderList) || parseInt(deliveryTypeOrderList)>999){
                layer.msg("排序请输入0-999的正整数!");
                return false;
            }



        }
        function changeDelivery(){
            var deliveryMethod=$("select[name='deliveryMethod']").val();
            if(deliveryMethod=='selfDelivery'){
                $("#defaultDeliveryCorp").hide();
                $("#firstWeight").hide();
                $("#continueWeight").hide();
                $("#firstWeightPrice").hide();
                $("#continueWeightPrice").hide();
            }else{
                $("#defaultDeliveryCorp").show();
                $("#firstWeight").show();
                $("#continueWeight").show();
                $("#firstWeightPrice").show();
                $("#continueWeightPrice").show();
            }
        }
    </script>
    <%
    var isAdd = false;
    var isEdit = false;
    if(isEmpty(deliveryType.id)){
    isAdd = true;
    }else{
    isEdit = true;
    }%>
</head>
<body>
<div class="path">
    配送方式 &raquo; <%if(isAdd){%>添加配送方式<%}else{%>编辑配送方式<%}%>
</div>
<form id="inputForm" class="" action="<%if (isAdd){%>${base}/shop/deliveryType/save<%}else{%>${base}/shop/deliveryType/update<%}%>" method="post" onsubmit="return check()">
    <input type="hidden" name="deliveryType.id" value="${deliveryType.id!}" />
    <table class="input tabContent">
        <tr>
            <th>
                配送方式名称:
            </th>
            <td>
                <input type="text" name="deliveryType.name" id="deliveryTypeName" class="formText" value="${deliveryType.name!}" />
                <label class="requireField">*</label>
            </td>
        </tr>
        <tr>
            <th>
                配送类型:
            </th>
            <td>
                <select name="deliveryMethod" id="deliveryMethod" onchange="changeDelivery()">
                    <%for(list in allDeliveryMethod){%>
                    <option value="${list}"<%if (list == deliveryType.deliveryMethod!){%> selected <%}%>>
                        ${i18n("DeliveryMethod." + list)}
                    </option>
                    <%}%>
                </select>
                <label class="requireField">*</label>
            </td>
        </tr>
        <tr id="defaultDeliveryCorp">
            <th>
                默认物流公司:
            </th>
            <td>
                <select name="deliveryType.defaultDeliveryCorp_id">
                    <option value="">请选择...</option>
                    <%for(list in allDeliveryCorp){%>
                    <option value="${list.id}" <%if (list.id == deliveryType.defaultDeliveryCorp_id!){%>selected <%}%>>
                ${list.name}
                    </option>
                    <%}%>
                </select>
            </td>
        </tr>
        <tr id="firstWeight">
            <th>
                首重量:
            </th>
            <td>
                <input type="text" name="deliveryType.firstWeight" class="formText" value="${deliveryType.firstWeight!0}" />
                <select name="firstWeightUnit">
                    <%for(list in allWeightUnit){%>
                    <option value="${list}"<%if (list == deliveryType.firstWeightUnit!){%> selected <%}%>>
                ${i18n("WeightUnit." + list)}
                    </option>
                    <%}%>
                </select>
                <span id="firstWeightMessagePosition"></span>
                <label class="requireField">*</label>
            </td>
        </tr>
        <tr id="continueWeight">
            <th>
                续重量:
            </th>
            <td>
                <input type="text" name="deliveryType.continueWeight" class="formText" value="${deliveryType.continueWeight!0}" />
                <select name="continueWeightUnit">
                    <%for(list in allWeightUnit){%>
                    <option value="${list}"<%if (list == deliveryType.continueWeightUnit!){%> selected <%}%>>
                ${i18n("WeightUnit." + list)}
                    </option>
                    <%}%>
                </select>
                <span id="continueWeightMessagePosition"></span>
                <label class="requireField">*</label>
            </td>
        </tr>
        <tr id="firstWeightPrice">
            <th>
                首重价格:
            </th>
            <td>
                <input type="text" name="deliveryType.firstWeightPrice" class="formText" value="${deliveryType.firstWeightPrice!0}" />
                <label class="requireField">*</label>
            </td>
        </tr>
        <tr id="continueWeightPrice">
            <th>
                续重价格:
            </th>
            <td>
                <input type="text" name="deliveryType.continueWeightPrice" class="formText" value="${deliveryType.continueWeightPrice!0}" />
                <label class="requireField">*</label>
            </td>
        </tr>
        <tr>
            <th>
                排序:
            </th>
            <td>
                <input type="text" name="deliveryType.orderList" id="deliveryTypeOrderList"  class="formText" value="${deliveryType.orderList!50}" title="只允许输入零或正整数" />
                <label class="requireField">*</label>
            </td>
        </tr>
        <tr>
            <th>
                介绍:
            </th>
            <td>
                <textarea name="deliveryType.description" class="" rows="14" cols="80">${deliveryType.description!}</textarea>
            </td>
        </tr>
    </table>
    <div class="buttonArea" style="margin-left: 165px;margin-top: 5px;">
        <input type="submit" id="submitbutton" class="button"  value="提交保存" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" class="button" onclick="window.history.back(); return false;" value="放弃保存" hidefocus="true" />
    </div>
</form>
</body>
</html>